package com.flyqiu.flow.bpmn.element;

import com.alibaba.fastjson2.JSONObject;
import lombok.Data;


@Data
public abstract class BaseProcElement implements IProcElement {
    private String defKey;
    private String defName;

    public static final String COMPLETE_CONDITION_KEY = "completeCondition";

    protected JSONObject element;

    protected ProcessModel processModel;


    /**
     * 初始化元素基本信息
     *
     * @param element
     * @param processModel
     */
    @Override
    public final void init(JSONObject element, ProcessModel processModel) {
        this.element = element;
        this.processModel = processModel;
        defKey = element.getString("defKey");
        defName = element.getString("defName");
        initElement(element, processModel);
    }


    /**
     * 初始化元素
     *
     * @param element
     * @param processModel
     */
    protected abstract void initElement(JSONObject element, ProcessModel processModel);


    @Override
    public String toString() {
        return String.format("{defKey:%s,defName:%s}", defKey, defName);
    }
}
